<%@ page import="java.util.List" %>
<%@ page import="utils.ExportExcelUtil" %>
<%@ page import="database.*" %>
<%@ page import="database.Class" %>
<%@ page import="javax.xml.stream.events.Comment" %>
<%--
  Created by IntelliJ IDEA.
  User: Thinkpad
  Date: 2016/12/9
  Time: 16:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>导出评价表</title>
</head>
<body>
<%
    int courseId = Integer.parseInt(request.getParameter("courseId"));
    if (courseId == 0) {
        response.getWriter().print("<script>location.href='../../error.jsp?error_code=101'</script>");
    } else {
        List<Course> courses = CourseDb.selectAllFinishedCourses(0, 999);
        List<CourseComment> comments = CommentDb.selectCommentsByCourseId(courseId, 0, 999);
        for (CourseComment comment : comments) {
            comment.setRating1();
            comment.setRating2();
            comment.setRating3();
        }
        try {
            String header[] = new String[4];
            header[0] = "课程#courseId";
            header[1] = "课程内容#rating1";
            header[2] = "教师水平#rating2";
            header[3] = "所得收获#rating3";
            String fileName = "课程评价表";
            String bigTitle = fileName;
            ExportExcelUtil.export(response, fileName, bigTitle, header, comments);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
%>

</body>
</html>
